package com.yc.streaming.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class TimeUtil {
	private static final String Time_FORMAT = "yyyy-MM-dd HH:mm:ss";

	public static String getTime() {
		SimpleDateFormat df = new SimpleDateFormat(Time_FORMAT);
		return df.format(new Date(System.currentTimeMillis()));
	}

	public static String getDate() {
		SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
		return df.format(new Date(System.currentTimeMillis()));
	}

	public static String getTime(String second) {
		SimpleDateFormat df = new SimpleDateFormat(Time_FORMAT);
        Long timestamp = Long.parseLong(second) * 1000;
		return df.format(new Date(timestamp));
	}

	public static String getTime(long d) {
		SimpleDateFormat df = new SimpleDateFormat(Time_FORMAT);
		return df.format(new Date(d));
	}

	public static String getDate(String second) {
		SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
		Long timestamp = Long.parseLong(second) * 1000;
		return df.format(new Date(timestamp));
	}

	public static void main(String[] args) {
		System.out.println(getDate("1479974306"));
		System.out.println(getDate());
        //System.out.println(getTime(1479451130));
        System.out.println(getTime(System.currentTimeMillis()));
	}
}
